import Vue from 'vue'
import Vuex from 'vuex'

Vue.use(Vuex)
//localhost:3000
//192.168.101.6:3000
export default new Vuex.Store({
  state: {
    token:'',
    userName:'',
    userID:'',
    rear_url:'localhost:3000',
    sellerID:'',
    cart:[]
  },
  mutations: {
    setTokenValue(state,value){
      state.token=value
    },
    setUserName(state,value){
      state.userName=value
    },
    clearLogging(state){
      state.userName=''
      state.token=''
      state.userID=''
    },
    clearCart(state){
      state.cart=[]
      state.sellerID=''
    },
    stuffCart(state,user_cart){
      state.cart=user_cart
    },
    setSellerID(state,sellerID){
      state.sellerID=sellerID
    },
    setUserID(state,userID){
      state.userID=userID
    }
  },
  getters:{
    getTokenValue:state=>state.token,
    getUserName:state=>state.userName,
    userInfoComplete:state=>{
      return state.userID!=''&&state.userName!=''&&state.token!=''
    }
  },
  actions: {
  },
  modules: {
  }
})
